//
//  YHLoginViewController.swift
//  Supplier_iOS
//
//  Created by ALH000355 on 2022/7/22.
//  Copyright © 2022 linlin. All rights reserved.
//

import UIKit
class YHLoginViewController: BaseViewController {

    static func show(from vc: UIViewController?) -> Void {
        let loginVC = YHLoginViewController()
        loginVC.modalPresentationStyle = .fullScreen
//        appDelegate.window?.rootViewController?.present(loginVC, animated: true, completion: nil)
    }
    // 手机号登录
    var phoneLoginView: YHLoginView!
    // 账号密码登录
    var userLoginView: YHLoginView!
    
    var loginBtn: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        uiConfig()
    }
    func uiConfig() {
        view.backgroundColor = .white
        let topView = UIView.init(frame: CGRect(x: 0, y: 0, width: screenWidth, height: 150))
        topView.backgroundColor = colorTheme
        view.addSubview(topView)
        let titleLb = UILabel.init(frame: CGRect(x: 24, y: 92, width: 235, height: 33))
        titleLb.text = "云配商城（商家端）"
        titleLb.textColor = .white
        titleLb.font = .systemFont(ofSize: 24, weight: .medium)
        topView.addSubview(titleLb)
        
        let selectWidth = screenWidth - 48
        let selectHeight = 46
        let selectView = YHSelectBtnView.init(frame: CGRect(x: 24, y: topView.bottom + 24, width: selectWidth, height: CGFloat(selectHeight)), titleArray: ["手机号登录", "账号登录"]) { [self] (value) in
            if value == Select_Status.Phone {
                self.phoneLoginView.isHidden = false
                self.userLoginView.isHidden = true
            } else {
                self.phoneLoginView.isHidden = true
                self.userLoginView.isHidden = false
            }
        }
        view.addSubview(selectView)
        let loginRect = CGRect(x: 0, y: selectView.bottom, width: screenWidth, height: 206)
        phoneLoginView = YHLoginView.init(frame: loginRect, status: .Phone)
        view.addSubview(phoneLoginView)
        
        userLoginView = YHLoginView.init(frame: loginRect, status: .User)
        phoneLoginView.isHidden = true
        view.addSubview(userLoginView)
        
        loginBtn = UIButton.init(type: .custom)
        loginBtn.frame = CGRect(x: 24, y: phoneLoginView.bottom + 32, width: screenWidth - 48, height: 44)
        loginBtn.setTitleColor(.white, for: .normal)
        loginBtn.setTitle("登录", for: .normal)
        loginBtn.titleLabel?.font = .systemFont(ofSize: 14)
        loginBtn.backgroundColor = colorTheme
        loginBtn.layer.cornerRadius = 4
        loginBtn.layer.masksToBounds = true
        view.addSubview(loginBtn)
        
        
        let callPhone = UIButton.init(type: .custom)
        callPhone.frame = CGRect(x: (screenWidth - 186) / 2, y: screenHeight - 110, width: 186, height: 20)
        callPhone.setTitleColor(.black.withAlphaComponent(0.75), for: .normal)
        callPhone.setTitle("客服热线：400-832-7799", for: .normal)
        callPhone.titleLabel?.font = .systemFont(ofSize: 14)
        callPhone.addTarget(self, action: #selector(clickCallAction), for: .touchUpInside)
        view.addSubview(callPhone)
        
        let wxTop = loginBtn.bottom + (callPhone.top - loginBtn.bottom - 86) / 2
        let wxView = YHWXLoginView.init(frame: CGRect(x: 0, y: wxTop, width: screenWidth, height: 86))
        view.addSubview(wxView)
    }
    
    @objc func clickCallAction() {
        
    }
    
}
